My Spatial Visualization Skills on Display.
This code will provide information on oil spills and their location throughout California State. A t-map will be produced as an interactive mode of exploring the data and a second static choropleth graph will be used to show a larger picture of the data within each county.
California Department of Fish and Game & Office of Spill Prevention and Response. (20089, July 23). Oil Spill Incident Tracking. Digital map and vector digital data. https://map.dfg.ca.gov/metadata/ds0394.html#ID0EUGA
oil_spills_sf <- read_sf(here("data/ds394/ds394.shp")) %>% # read in shape file
clean_names() %>%
st_transform(3310) # transform coordinate system
ca_counties <- read_sf(here("data/CA_Counties/CA_Counties_TIGER2016.shp")) %>% # read in shape file
clean_names() %>%
st_transform(3310) # transform coordinate system
tmap_mode(mode = "view") # interactive t-map option
tmap_options(check.and.fix = TRUE,
max.categories = 58)
tm_shape(ca_counties) + # start by using CA counties
tm_fill("aland", # fill by land area
palette = "BuGn",
popup.vars = c("County:" = "namelsad")) + # add a popup variable
tm_borders(col = "black") + # add borders around the counties
tm_shape(oil_spills_sf) + # add another layer
tm_dots(popup.vars = c("Control Number:" = "oesnumber", # add more popup variables
"Date:" = "dateofinci",
"Time:" = "timeofinci",
"County:" = "localecoun",
"City:" = "localecity",
"Type of Water:" = "specificlo",
"Inland or Marine:" = "inlandmari"),
size = 0.02) # change size of points